package com.woniu.shirocore;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.env.BasicIniEnvironment;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;

/**
 * @author Rain
 * @Description :
 * @date 2022/09/05 14:49
 */
public class LoginAuthBasicDemo {

    public static void main(String[] args) {
        BasicIniEnvironment basicIniEnvironment = new BasicIniEnvironment("classpath:ini/shiro-auth.ini");
        SecurityManager securityManager = basicIniEnvironment.getSecurityManager();
        SecurityUtils.setSecurityManager(securityManager);
        Subject subject = SecurityUtils.getSubject();

        subject.login(new UsernamePasswordToken("rain","654321"));

        System.out.println(subject.getPrincipal()+ "登陆成功"+subject.isAuthenticated());
    }
}
